package com.ztmmm.module.repo.mapper;

import com.ztmmm.module.repo.entity.Repo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 题库 Mapper 接口
 * </p>
 *
 * @author ztm
 * @since 2023-03-20
 */
@Mapper
public interface RepoMapper extends BaseMapper<Repo> {
    @Select("update el_repo set\n" +
            "            radio_count = (select count(*) from el_qu_repo where el_qu_repo.repo_id = #{repoId}\n" +
            "            and el_qu_repo.qu_type = '1'),\n" +
            "            multi_count = (select count(*) from el_qu_repo where el_qu_repo.repo_id = #{repoId}\n" +
            "            and el_qu_repo.qu_type = '2'),\n" +
            "            judge_count = (select count(*) from el_qu_repo where el_qu_repo.repo_id = #{repoId}\n" +
            "            and el_qu_repo.qu_type = '3'),\n" +
            "            jdt_count = (select count(*) from el_qu_repo where el_qu_repo.repo_id = #{repoId}\n" +
            "            and el_qu_repo.qu_type = '4')\n" +
            "            where id = #{repoId}"
    )
    void updateRepoCount(@Param("repoId") String repoId);

}
